<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" href="../css/mui.min.css">
	<link rel="stylesheet" type="text/css" href="../css/goods/shouhou_add_address.css" />
	<link rel="stylesheet" href="../css/goods/iconfont.css">

	<!-- <link rel="stylesheet" type="text/css" href="../css/goods/confirm_order.css" /> -->
	<link rel="stylesheet" href="../css/mui.picker.min.css">
	<script type="text/javascript">
		(function () {
			var clientWidth = document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
			clientWidth = clientWidth || localStorage.getItem("clientWidth")
			if (clientWidth > 750)
				clientWidth = 750;
			document.documentElement.style.fontSize = clientWidth * 1 / 16 + "px";
		})();
	</script>
	<style>
		html,
		body,
		.mui-content {
			background-color: #f6f6f6;
		}

		.ptsp_top_stats {
			height: 20px;
			width: 100%;
			background-color: #ffffff;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 10000;
		}

		.mui-action-back {
			height: 44px;
			width: 44px;
		}

		.mui-action-back img {
			width: 100%;
		}



		.mui-content {
			padding-bottom: 100px;
			padding-top: 44px !important;
		}

		.arr_left {
			background-image: url(../images/ptsp/left_arr_03.png);
			background-size: 24px 24px;
			background-position: center;
			background-repeat: no-repeat;
		}

		.mui-title {
			font-size: 0.768rem;
		}

		.mui-bar-nav a {
			font-size: 0.5973rem;
			color: #888888;
			line-height: 44px;
		}
	</style>
</head>

<body>

	<header class="mui-bar mui-bar-nav" style="border-bottom: 1px solid #c5c5c5">
		<a class="mui-action-back mui-icon  mui-pull-left arr_left">
		</a>
		<h1 class="mui-title">编辑个人信息</h1>
		<a class="mui-pull-right" onclick="app.sub_this()">提交</a>
	</header>
	<div class="mui-content">

		<div class="address_form">
			<div class="hr_20"></div>
			<div class="imgs">
				<div class="text_row_80" style="border: none; font-size: 14px;">点击头像更换</div>
				<div id="has_img">

					<div class="img_item" @click="open_pic">
						<div class="has_img">
							<img :src="user.head" />
						</div>
					</div>

				</div>

			</div>
			<div class="hr_20"></div>
			<div class="text_row_100">
				<span class="fl fs_28">昵称 :</span>
				<input class="fl fs_24 input" v-model="user.nickname" type="text" placeholder="请输入昵称" />

			</div>
			<div id="sheet1" class="mui-popover mui-popover-bottom mui-popover-action ">
				<!-- 可选择菜单 -->
				<ul class="mui-table-view">
					<li class="mui-table-view-cell" id="paizhao">
						<a href="#">拍照</a>
					</li>
					<li class="mui-table-view-cell" id="xiangce">
						<a href="#">相册</a>
					</li>
				</ul>
				<!-- 取消菜单 -->
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a href="#sheet1">
							<b>取消</b>
						</a>
					</li>
				</ul>
			</div>


		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script src="../js/jquery.min.js"></script>
		<script src="../js/tools/util.js"></script>
		<script src="../js/tools/upload_head_img.js"></script>
		<script src="../js/host.config.js"></script>
		<script>
			var app = new Vue({
				el: '.mui-content',
				data: {
					user: '',
					add_img_flag: '',
					plusready: false,
				},
				methods: {
					open_pic: function () {
						mui('#sheet1').popover('toggle');
					},
					sub_this: function () {
						var that = this;
						// 提交更改后的用户信息
						console.log("头像-->" + this.user.head)
						console.log("昵称-->" + this.user.nickname)
						//                      参数：uid:用户id    head：头像    nickname：用户名
						
//						alert("头像-->" + this.user.head)
//						alert("昵称-->" + this.user.nickname)
//						alert("uid-->" + this.user.uid)
//						alert("account_type-->"+this.user.account_type)
						$.ajax({
							type: "post",
							url: host_config.app_server + 'user/App_UserData',
							data: {
								uid: this.user.uid,
								head: this.user.head,
								nickname: this.user.nickname,
								account_type: this.user.account_type
							},
							success: function (res) {
								console.log(res);
								res = JSON.parse(res);
								console.log(res);

								if (res.code == 1) {

									mui.toast("修改成功")
									if (that.plusready) {
										console.log("plusready-关闭当前页，刷新上一页");
										localStorage.setItem("user", JSON.stringify(that.user));
										var my = plus.webview.currentWebview().opener();
										if (my) {
											my.reload()
										}
										plus.webview.currentWebview().close();
									}


								}
							},
							error: function (err) {
								console.log(err)
							}
						})


					},

				},
				created: function () {
					var that = this;
					mui.plusReady(function () {
						that.plusready = true
					})
					// 初始化用户信息
					user_info_init(this)
					

				},
				mounted: function () {
					var that = this;
					// 初始化 拍照 相册 选择
					
					ts.select_img('xiangce', function (path) {
						mui('#sheet1').popover('hide');
						that.user.head = path;
					});
					ts.get_img('paizhao', function (path) {
						mui('#sheet1').popover('hide');
						that.user.head = path;
					});
					
				}
			})
			// 初始化用户信息
			function user_info_init(that) {
				var user = get_user_info();
				if (user) {
					that.user = user;
				} else {
					mui.toast("未登录");
					mui.openWindow("logon.html", "logon.html")
				}
			}
		</script>
	</div>
</body>

</html>
